//
//  UserViewController.m
//  礼物
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "UserViewController.h"

@interface UserViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * myTableView;
@end

@implementation UserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.myTableView=[[UITableView alloc]initWithFrame:MAINSCREEN style:UITableViewStylePlain];
    self.myTableView.dataSource=self;
    self.myTableView.delegate=self;
    [self.view addSubview:self.myTableView];

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *inditifer=@"reuse";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:inditifer];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:inditifer];
    }
    if (indexPath.row==0) {
        cell.textLabel.text=@"我的收藏";
        
    }if (indexPath.row==1) {
        cell.textLabel.text=@"清除缓存";
        
    }
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row==0) {
    CollectionViewController *collectionVC=[[CollectionViewController alloc]init];
    [self.navigationController pushViewController:collectionVC animated:YES];
    }if (indexPath.row==1) {
        NSInteger size=[[SDImageCache sharedImageCache]getSize];
        float totalSize = size / 1024.0 / 1024.0;
        
        NSString *str=[NSString stringWithFormat:@"缓存大小:%.2fMB",totalSize];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"缓存清除成功" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
        //清除缓存
        [[SDImageCache sharedImageCache]clearDisk];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
